{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Ungraded Lab: Decision Boundary\n",
    "\n",
    "\n",
    "In this lab, you will plot the decision boundary for a logistic regression model, which will give you a better sense of what the model is predicting.\n",
    "\n",
    "\n",
    "## Dataset\n",
    "\n",
    "Let's suppose you have following training dataset\n",
    "- The input variable `X` is a numpy array which has 6 training examples, each with two features\n",
    "- The output variable `y` is also a numpy array with 6 examples, and `y` is either `0` or `1`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "\n",
    "X = np.array([[0.5, 1.5], [1,1], [1.5, 0.5], [3, 0.5], [2, 2], [1, 2.5]])\n",
    "y = np.array([0, 0, 0, 1, 1, 1])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Plot data \n",
    "\n",
    "Let's use a helper function to plot this data. The data points with label $y=1$ are shown as red crosses, while the data points with label $y=0$ are shown as black circles. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Text(0.5, 0, '$x_1$')"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX0AAAEMCAYAAAAoB2Y1AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAAAOBUlEQVR4nO3db4xldX3H8c+H3TU6i4W0jnbjsjuYNBCiKdgprV1r7BIoFkL7wAfa1QdqOkljDUYbg13NzrbdNH1iJKZpMl2wGEepAUkNbVESUEpT0BlYy5/FxhAWlmB2SEPYdRsp+OmDe1eW2Z2dmZ17zrlzv+9XMtl7Z87w+10I7z3zm3PPz0kEAKjhnK4nAABoD9EHgEKIPgA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foAUAjRB86gf7voK/uP/9r2l7qeE7AWQ/PmLGBI7ZH0l7bfrN5N5K7reD7AmvDmLGAZtr8n6VxJ701y1PbbJO2WdF6S93c7O2B1WN4BzsD2O9S7DcNL/X0C1N/z4WPdzgw4O0QfWEJ/N7BZ9TbzOWZ7lO6siaKIPnAatsckfVPSp5MclPRX6q3vA+saa/rAKtn+FUn71LvF8v4kf9PxlIAVI/oAUAjLOwBQCNEHgEKIPgAUQvQBoBCiDwCFEH0AKIToA0AhRB8ACiH6AFDI/wMCz9Itm1b3nwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "from lab_utils import plot_data\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "plot_data(X, y)\n",
    "\n",
    "# Set both axes to be from 0-6\n",
    "plt.axis([0, 6, 0, 6])\n",
    "# Set the y-axis label\n",
    "plt.ylabel('$x_2$')\n",
    "# Set the x-axis label\n",
    "plt.xlabel('$x_1$')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Logistic regression model\n",
    "\n",
    "\n",
    "* Suppose you'd like to train a logistic regression model on this data which has the form   \n",
    "\n",
    "  $f(x) = g(w_0 + w_1x_1+w_2x_2)$\n",
    "  \n",
    "  where $g(z) = \\frac{1}{1+e^{-z}}$, which is the sigmoid function\n",
    "\n",
    "\n",
    "* Let's say that you trained the model and get the parameters as $w_0 = -3, w_1 = 1, w_2 = 1$. That is,\n",
    "\n",
    "  $f(x) = g(-3 + x_1+x_2)$\n",
    "\n",
    "  (You'll learn how to fit these parameters to the data further in the course)\n",
    "  \n",
    "  \n",
    "Let's try to understand what this trained model is predicting by plotting it's decision boundary"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Refresher on logistic regression and decision boundary\n",
    "\n",
    "* Recall that for logistic regression, the model is represented as \n",
    "\n",
    "  $f(x) = g(w^Tx)$\n",
    "\n",
    "  where\n",
    "\n",
    "  $g(z) = \\frac{1}{1+e^{-z}}$\n",
    "  \n",
    "  $g(z)$ is known as the sigmoid function and it maps all input values to values between 0 and 1.\n",
    "  \n",
    "\n",
    "* We interpret the output of the model ($f(x)$) as the probability that $y=1$ given $x$ and parameterized by $w$.\n",
    "* Therefore, to get a final prediction ($y=0$ or $y=1$) from the logistic regression model, we can use the following heuristic -\n",
    "\n",
    "  if $f(x) >= 0.5$, predict $y=1$\n",
    "  \n",
    "  if $f(x) < 0.5$, predict $y=0$\n",
    "  \n",
    "  \n",
    "* Since, $f(x) = g(w^Tx)$, let's plot the sigmoid function to see where $g(z) >= 0.5$\n",
    "\n",
    "We've implemented the `sigmoid` function for you already and you can simply import and use it, as shown in the code block below."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Text(0, 0.5, '(x=0, y=0.5)')"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD4CAYAAAD8Zh1EAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAAAb40lEQVR4nO3de3hV9Z3v8fc3QRQtBcGIaQIEJaIoiBq8VCmOwBywClprkQefjhfA8dF2tFbH1nqf8TJO7fR4aQ9azjhOjowHq2VaKm0CiJ6qGAtiwmVCqUICIgNYvHDP9/zx28FNSMjOzt5Z+/J5Pc961jV7f7uezcdff+u31jJ3R0REsl9B1AWIiEhqKNBFRHKEAl1EJEco0EVEcoQCXUQkR3SL6ouPOeYYLysri+rrRUSy0jvvvPPf7l7U2r7IAr2srIyampqovl5EJCuZ2Qdt7VOXi4hIjlCgi4jkCAW6iEiOUKCLiOQ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4nQRZRJgb7JzIrdfaOZFQMfRV1QM3ff1Lwc9W/NzA4jhHmlu/8ytjmpc5dVXS5mNh64HZjo7p/H7ZoLXGlmh5vZIKAcWBJFjS2ZWZGZFcaWjyfUtjbaqvbLqPMW++E2uwyobevYLpLIC9IjYWZHmVnP5mXCgIGoz1dL8S+P/xsgk/6fYkb81iw0xX8BrHT3x+J2JXfuor7K28ErwmsIfZrLYtPP4/bdSRiRsBqYEEFtlxH6WHcBm4D5se2XA3Wxev8IXJIptWXCeWtR53PAe8Dy2A+6OAN+cxcRRh78idB9FWk9cXUdTxh1827s9xVpbcDzhO7FPbHf2nVAX6AaqAeqgD4ZVFtG/NaA8wndPsvjcu2iZM+dbv0XEckRWdXlIiIibVOgi4jkCAW6iEiOUKCLiOQIBbqISI5QoIuI5AgFuohIjvj/ijrcS8pnZU0AAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "from lab_utils import sigmoid\n",
    "\n",
    "\n",
    "# Plot sigmoid(z) over a range of values from -20 to 20\n",
    "z = np.arange(-20,20)\n",
    "plt.plot(z, sigmoid(z), c=\"b\")\n",
    "\n",
    "# Plot and annotate the point where sigmoid(z) = 0.5\n",
    "plt.plot(0, sigmoid(0), 'ro')\n",
    "plt.text(0, sigmoid(0), '(x={}, y={})'.format(0, sigmoid(0)))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* As you can see, $g(z) >= 0.5$ for $z >=0$\n",
    "\n",
    "* For a logistic regression model, $z = w^Tx$. Therefore,\n",
    "\n",
    "  if $w^Tx >= 0$, the model predicts $y=1$\n",
    "  \n",
    "  if $w^Tx < 0$, the model predicts $y=0$\n",
    "  \n",
    "  \n",
    "  \n",
    "### Plotting decision boundary\n",
    "\n",
    "Now, let's go back to our example to understand how the logistic regression model is making predictions.\n",
    "\n",
    "* Our logistic regression model has the form\n",
    "\n",
    "  $f(x) = g(-3 + x_1+x_2)$\n",
    "\n",
    "\n",
    "* From what you've learnt above, you can see that this model predicts $y=1$ if $-3 + x_1+x_2 >= 0$\n",
    "\n",
    "Let's see what this looks like graphically. We'll start by plotting $-3 + x_1+x_2 = 0$, which is equivalent to $x_2 = 3 - x1$.\n",
    "\n",
    "**Exercise**\n",
    "\n",
    "Complete the code block below by writing `x2 = 3-x1`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Text(0.5, 0, 'x1')"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXsAAAEKCAYAAADzQPVvAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAAAY6klEQVR4nO3deZRU9ZnG8e/LJi2KGiSKgiNRo+wCLeKCUeICkkEcNMEt7mjcIKJBo8jiEjERBxcSEEFEkE2aKCKCiDEeN8BtXMiYMSaiGHHvql7o7nrnjyoyjHZDA3X7VtXv+ZzDsbu5Vb+njsfH27duvT9zd0REpLA1ijuAiIhET2UvIhIAlb2ISABU9iIiAVDZi4gEQGUvIhKASMvezHY3swVmttbM3jWzI6JcT0REatck4uefCCx199PMrBmwc8TriYhILSyqD1WZ2W7A68APXJ/cEhGJVZRn9u2BDcB0M+sGrAGGuXty84PMbCgwFKBFixY9DznkkAgjiYgUljVr1nzm7q23dlyUZ/bFwEvAUe7+splNBL5x91F1Paa4uNhXr14dSR4RkUJkZmvcvXhrx0X5Bu06YJ27v5z5fgHQI8L1RESkDpGVvbt/AnxoZgdnfvRj4J2o1hMRkbpFfTfOlcCszJ047wPnR7yeiIjUItKyd/fX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Zo8AxwJ7mtk6YLS7PxBvqqw6CjgH+K/MdW2AX7v7kvgiZVUbYEbmrrFGwDx3L7hbFAvUXkBJ+nyEJsBsd18ab6SsuxKYlTlRfh84v64DY7/1UkREopcLl3FERCRiKnsRkQCo7EVEAqCyFxEJgMpeRCQAKnuRejCzpWb2VSFOhpQwqOxF6ue3pD9PIJKXVPYimzGzw8zszcwc+xaZGfad3X0FUBp3PpHtFfsnaEVyibuvMrPHgFuAIuBhdy+Yj9hLuFT2It81jvTMpgrgqpiziGSFLuOIfFcrYBdgV6B5zFlEskJlL/Jdk4FRwCxgfMxZRLJCl3FENmNmPweq3H12ZtLlC2bWFxgLHALskpleeqG7PxVnVpFtoamXIiIB0GUcEZEAqOxFRAKgshcRCYDKXkQkACp7EZEAqOxFRAKgshcRCcD/Aq19SSuQ4iNHAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Choose values between 0 and 6\n",
    "x1 = np.arange(0,6)\n",
    "\n",
    "### START CODE HERE ### \n",
    "### BEGIN SOLUTION ###  \n",
    "x2 = 3 - x1\n",
    "### END CODE HERE ###\n",
    "### END SOLUTION ###  \n",
    "# Plot the decision boundary\n",
    "plt.plot(x1,x2, c=\"b\")\n",
    "plt.axis([0, 6, 0, 6])\n",
    "\n",
    "# Fill the region below the line\n",
    "plt.fill_between(x1,x2, alpha=0.2)\n",
    "\n",
    "# Plot the original data\n",
    "plot_data(X,y)\n",
    "# Set the y-axis label\n",
    "plt.ylabel('x2')\n",
    "# Set the x-axis label\n",
    "plt.xlabel('x1')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* In the plot above, the blue line should represent the line $-3 + x_1+x_2 = 0$ and it should intersect the x1 axis at 3 (if we set $x_2$ = 0, $x_1$ = 3) and the x2 axis at 3 (if we set $x_1$ = 0, $x_2$ = 3). \n",
    "\n",
    "\n",
    "* The shaded region represents $-3 + x_1+x_2 < 0$. The region above the line is $-3 + x_1+x_2 > 0$.\n",
    "\n",
    "\n",
    "* Therefore, for this model any point in the shaded region (under the line) is classified as $y=0$ and any point on or above the line is classified as $y=1$. This line is known as the \"decision boundary\".\n",
    "\n",
    "As we've seen in the videos, by using higher order polynomial terms (eg: $f(x) = g(-1 + x_1^2 + x_2^2)$, we can come up with more complex non-linear boundaries."
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
